package calculate;

/**
 * use only the simple floating point calculation, 
 * only precise to the 15th digit
 * 
 * v1. use floating point:
 * output:  3243F6A8885A306
 * currect: 3243F6A8885A308
 * 
 * @author zcz
 *
 */
public class FloatCalculous extends Basic {
	
	public FloatCalculous(int k) {
		super(k);
	}

	public void calculous() {
		double d = 0;
		double t = 0;
		int k = 0;
		for (int i = 0; i <= this.preciseDigit; ++i) {
			t  = 0;
			t += this.part(1, 4, i);
			t -= this.part(4, 2, i);
			t -= this.part(5, 1, i);
			t -= this.part(6, 1, i);

			d = d * 16 + t;
			k = this.getFirstDigit(d);
			d -= k;
			
			this.hex[i] = k;
		}
	}
		
	//calculous the small part as : (b) / (8 * k + a) 
	public double part( double a, double b, double k ) {
		return ((b)/(8*k + a));
	}	
}
